//
//  ListenCollectionViewCell.m
//  MarianasTrench
//
//  Created by 付建国 on 16/3/18.
//  Copyright © 2016年 王爵. All rights reserved.
//

#import "ListenCollectionViewCell.h"

@interface ListenCollectionViewCell ()

@property (nonatomic, strong) UIImageView *imageV;
@property (nonatomic, strong) UILabel *titleL;
@property (nonatomic, strong) UILabel *digestL;
@property (nonatomic, strong) UILabel *numberL;

@end

@implementation ListenCollectionViewCell

- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        [self createSubViews];
    }
    return self;
}
// 重写setter方法
- (void)setModel:(ListModel *)model{
    _model = model;
    [self fuzhi];
}
- (void)fuzhi{
//    [self.imageV sd_setImageWithURL:[NSURL URLWithString:_model.coverPath]];
    dispatch_async(dispatch_get_main_queue(), ^{
        
        [self.imageV HANDLEIMAGE(_model.coverPath)];
    });
    
    self.titleL.text = _model.title;
    self.titleL.font = [UIFont systemFontOfSize:15];
    
    self.digestL.text = _model.subtitle;
    self.digestL.font = [UIFont systemFontOfSize:12];
    self.digestL.textColor = [UIColor grayColor];
    
    self.numberL.text = _model.footnote;
    self.numberL.font = [UIFont systemFontOfSize:10];
    self.numberL.textColor = [UIColor grayColor];
}
- (void)createSubViews{
    
    self.imageV = [[UIImageView alloc] init];
    [self.contentView addSubview:_imageV];
    
    self.titleL = [[UILabel alloc] init];
    [self.contentView addSubview:_titleL];
    
    self.digestL = [[UILabel alloc] init];
    [self.contentView addSubview:_digestL];
    self.digestL.numberOfLines = 10;
    
    self.numberL = [[UILabel alloc] init];
    [self.contentView addSubview:_numberL];
    
}

- (void)applyLayoutAttributes:(UICollectionViewLayoutAttributes *)layoutAttributes{
    [super applyLayoutAttributes:layoutAttributes];
    self.imageV.frame = CGRectMake(0, 0, layoutAttributes.size.height - 5, layoutAttributes.size.height - 5);
    
    self.titleL.frame = CGRectMake(layoutAttributes.size.height, 0, layoutAttributes.size.width - layoutAttributes.size.height - 10, 20);
    
    self.digestL.frame = CGRectMake(layoutAttributes.size.height, 20, layoutAttributes.size.width - layoutAttributes.size.height - 10, 40);
    
    self.numberL.frame = CGRectMake(layoutAttributes.size.height, layoutAttributes.size.height - 20, layoutAttributes.size.width - layoutAttributes.size.height - 10, 20);
}








@end
